package com.itstyle.quartz.config;

import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.processor.StandardXmlNsTagProcessor;
import org.thymeleaf.templatemode.TemplateMode;
import java.util.HashSet;
import java.util.Set;

public class CustomDialect extends AbstractProcessorDialect {

    private static final String DIALECT_NAME = "CustomDialect";
    private static final String DIALECT_PREFIX = "custom"; // 模板中使用的前缀（如 xmlns:custom）
    private static final int PRECEDENCE = org.thymeleaf.standard.StandardDialect.PROCESSOR_PRECEDENCE;

    public CustomDialect() {
        super(DIALECT_NAME, DIALECT_PREFIX, PRECEDENCE);
    }

    @Override
    public Set<IProcessor> getProcessors(String dialectPrefix) {
        Set<IProcessor> processors = new HashSet<IProcessor>();
        // 添加 data-src 属性处理器
        processors.add(new CustomDataSrcProcessor(dialectPrefix));
        // 保留 xmlns 命名空间处理（必须添加）
        processors.add(new StandardXmlNsTagProcessor(TemplateMode.HTML, dialectPrefix));
        return processors;
    }
}
